home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / arc / SNESDiz.lha / SNESDiz / Source / SnesDiz.Rexx
OS/2 REXX Batch file  |  1999-02-11  |  10KB  |  323 lines

  1. /*
  2.  
  3. Super Nintendo Entertainment System File Identity Description Creator
  4. $VER: SNESDiz 1.8 by DaFoX / OmenBBS
  5.  
  6. */
  7.  
  8. SAY ""
  9. SAY "    [ SNESDiz 1.8  DaFoX / OmenBBS ]"
  10. SAY ""
  11.  
  12. /*
  13. signal on break_c
  14. signal on syntax
  15. signal on ioerr
  16. */
  17.  
  18. If ~show('L', 'rexxdossupport.library') then do
  19.   if ~addlib('rexxdossupport.library', 0, -30, 0) then do
  20.    say "rexxdossupport.library not available, exiting ..."
  21.    exit 20
  22.   end
  23. end
  24.  
  25. parse arg args
  26.  
  27. template = "Files/M,Diz/S,Ftp/S,Com/S,List/s,All/s"
  28.  
  29. call ReadArgs(args,template)
  30. call ReadArgs(args,template,"args.")
  31.  
  32. If ~show('L', 'rexxreqtools.library') then do
  33.   if ~addlib('rexxreqtools.library', 0, -30, 0) then do
  34.    say "rexxreqtools.library not available, exiting ..."
  35.    exit 20
  36.   end
  37. end
  38.  
  39. if ~list & args.files.count=0|args.files.0="?" then do
  40.   say "Usage: FILES/M,DIZ/S,FTP/S,COM/S,LIST/S"
  41.   Say "or start it without options and select SNES file ;)"
  42.   args.files.0 = rtfilerequest('ram:',,"Pick a Super Nintendo file:", ,,
  43.                          'rt_reqpos=reqpos_centerscr')
  44.   if args.files.0~="" then args.files.count=1
  45.   else exit
  46. end
  47.  
  48. if pos("?",args.files.0)~=0 then do
  49. if all=1 then args.files.0=args.files.0' All'
  50.   address command 'list 'args.files.0 ' Files >T:SNESList Lformat %P%N'
  51.   list=1
  52.   args.files.0="T:SNESList"
  53. end
  54. cdiz=diz
  55.  
  56. if diz & ~FTP then do
  57.   say "Creating File_Id.diz"
  58.  
  59.   if list=1 then do
  60.      call open filel,args.files.0
  61.      do until eof(filel)
  62.        Afile=readln(filel)
  63.        if Afile~="" then do;call open skriv,left(afile,pos(".",afile)-1)".diz","W";call dodiz;call close skriv;end
  64.      end
  65.   end
  66.   if args.files.count~=1 & ~list then do
  67.      do I=0 to args.files.count-1
  68.        Afile=args.files.I
  69.        if Afile~="" then do;call open skriv,left(afile,pos(".",afile)-1)".diz","W";call dodiz;call close skriv;end
  70.      end
  71.   end
  72.   else do;Afile=args.files.0;call open skriv,"File_Id.diz","W";call dodiz;end
  73.  
  74.   exit
  75. end
  76.  
  77. if FTP then do
  78.   if Diz then do
  79.     If ~show('L','rexxsupport.library') then do
  80.       if ~addlib('rexxsupport.library', 0, -30, 0) then do
  81.        say "rexxsupport.library not available, exiting ..."
  82.        exit 20
  83.       end
  84.     end
  85.   end
  86.   if exists('index') then do
  87.   call rtezrequest("Append or OverWrite Index file",,
  88.                  "_Append|_OverWrite","Tell me", 'rt_reqpos=reqpos_centerscr')  
  89.  
  90.     if rtresult == 1
  91.      then call open skriv,"index","A"
  92.     else call open skriv,"index","W"
  93.  
  94.   end
  95.   else call open skriv,"index","W"
  96.   if ~LIST then do
  97.     do i = 0 by 1 for args.files.count
  98.       afile=args.files.i
  99.       call dodiz
  100.     end
  101.     exit
  102.    end
  103. end
  104.  
  105. if LIST then do
  106.   if ~exists(args.files.0) then do
  107.     say "Wath list???";exit
  108.   end
  109.   call open filel,args.files.0
  110.   do until eof(filel)
  111.     Afile=readln(filel)
  112.     if Afile~="" then call dodiz
  113.   end
  114.   exit
  115. end
  116.  
  117. do i = 0 by 1 for args.files.count
  118.   afile=args.files.i
  119.   call dodiz
  120. end
  121. exit
  122.  
  123. dodiz:
  124. if ~exists(Afile) then do
  125.   say "Can't open" Afile;return
  126. end
  127. if right(Afile,3)=".gz" then do
  128.   address command 'gunzip -c 'afile'  > t:snestmp'
  129.   call open file,"t:snestmp"
  130. end
  131. if left(right(Afile,2),1)="." then do
  132.   if c2d(Afile,1)>1 then call open file,Left(AFile,length(Afile)-1)'1'
  133. end
  134.  
  135. else call open file,Afile
  136.  
  137.  
  138. x=0;cprom=0
  139.  
  140. call seek(file,256)
  141. pas1=readch(file,256)
  142.  
  143. /*if c2x(left(readch(file,256),16))~="00000000000000000000000000000000" then*/
  144.  
  145. if left(pas1,16)~=right(left(pas1,32),16) then do
  146.   cprom=1;seek(file,0,'B')
  147. end
  148.  
  149. call seek(file,32704)
  150. pas1=readch(file,27)
  151. test1=c2x(left(pas1,21))
  152.  
  153. do a=2 to 21 by 2
  154. /*say left(left(test1,a),2) x2d(left(test1,a),2)*/
  155.  
  156.   if x2d(left(test1,a),2) > 120 then x=x+1
  157.   if x2d(left(test1,a),2) < 32 then x=x+1
  158. end
  159. /*say x*/
  160. if x<2 then do
  161.  diz=left(pas1,21)
  162.  mr=c2x(pas1)
  163.  rommet="low"
  164.  end
  165. else do
  166.   y=0
  167.   call seek(file,32725)
  168.   bck=readch(file,16)
  169.   pas2=readch(file,27)
  170.  
  171.     test1=c2x(left(pas2,21))
  172.     do a=2 to 21 by 2
  173.       if x2d(left(test1,a),2) > 120 then y=y+1
  174.       if x2d(left(test1,a),2) < 32 then y=y+1
  175.     end
  176.  
  177.   if y<x then do;diz=left(pas2,21); rommet="high";mr=c2x(pas2);end
  178.   if y>x then do;diz=left(pas1,21); end
  179.   if pas1=pas2 then diz=left(pas1,21)
  180.   if diz="" then diz="unknown"
  181. end
  182. GameType=right(left(mr,46),2)
  183. GameSize=x2d(right(left(mr,48),2))
  184. BackupSize=x2d(right(left(mr,50),2))
  185. Country=x2d(right(left(mr,52),2))
  186. Manufactor=x2d(right(left(mr,54),2))
  187. Version=x2d(right(left(mr,56),2))+1
  188.  
  189. /*
  190. BackupSize=x2d(right(left(mr,50),2))
  191. Version=x2d(right(left(mr,52),2))+1
  192. Manufactor=x2d(right(left(mr,54),2))
  193. */
  194.  
  195. if GameType=0 then GameType="Rom"
  196. if GameType=1 then GameType="Rom+Ram"
  197. if GameType=2 then GameType="Rom+Backup"
  198. if GameType=3 then GameType="Rom+Dsp1"
  199. if GameType=4 then GameType="Rom+Ram+Dsp1"
  200. if GameType=5 then GameType="Rom+Backup+Dsp1"
  201. if GameType=0 then GameType="FX"
  202.  
  203. if Country=0 then Country="Japan (NTSC)"
  204. if Country=1 then Country="U.S.A (NTSC)"
  205. if Country=2 then Country="Australia, Europe, Oceania, Asia"
  206. if Country=3 then Country="Sweden"
  207. if Country=4 then Country="Finland"
  208. if Country=5 then Country="Denmark"
  209. if Country=6 then Country="France"
  210. if Country=7 then Country="Holland"
  211. if Country=8 then Country="Spain"
  212. if Country=9 then Country="Germany, Austria and Switzerland"
  213. if Country=10 then Country="Italy"
  214. if Country=11 then Country="Hong Kong and China"
  215. if Country=12 then Country="Indonesia"
  216. if Country=13 then Country="Korea"
  217.  
  218. if gamesize~=0 then do
  219.  Size=8
  220.   do a=1 to Gamesize
  221.   size=size*2
  222.  end
  223.  if size>512 then Gamesize=Size/1024 'MBit'
  224.   else Gamesize=Size 'Kbit'
  225.  end
  226. Else Gamesize="None"
  227.  
  228. if Backupsize~=0 then do
  229.  Size=8
  230.   do a=1 to Backupsize
  231.   size=size*2
  232.  end
  233.  if size>512 then Backupsize=Size/1024 'MBit'
  234.   else Backupsize=Size 'Kbit'
  235.  end
  236. Else Backupsize="None"
  237.  
  238. If Manufactor=51 then do
  239.   /*
  240.   say c2x(left(bck,1))
  241.   say (x2d(c2x(left(bck,1)))-48)*16
  242.   say x2d(c2x(right(left(bck,2),1)))-48
  243.   
  244.   VERY EXPREMENTAL
  245.   
  246.   */
  247.   Manufactor=(x2d(c2x(left(bck,1)))-48)*16+x2d(c2x(right(left(bck,2),1)))-48
  248. end
  249. if manufactor>255|manufactor<1 then Manufactor=4
  250. manuf = 'Nintendo Ajinomoto Imagineer u Zamuse Falcom u Capcom Activision Jaleco Storm u Micronet Technos Mebio_Software u u Gremlin ECA NCS Cobra_Team Human KOI Hudson_Soft B-ai Yanoman u Temco u Forum Park_Place_Prod. IKSS Tokai_Engeneering Pow Loriciel u u Enix Loriciel Kemco Seta Culture_Brain Williams_ent. Sotsu_Agency Visit Intec System_Sacom Viacom Carrozzeria Dynamic u Magicfact Epyx u u u u u u Empire Loriciel Gremlin u Seika Ubisoft u u u u Sculpture Spectrum_Holobyte u Irem u Raya_Systems Renovation_Pr. T*HQ_inc. u U.S.Gold Absolute_Ent. Acclaim Activision American_Sammy Gametek HiTech_Expressions LJN u u u Mindscape Romstar u Tradewest u American_Softworks Titus Virgin Maxis Origin_Games u u u Ocean_Software u Electronic_Arts u Laser_Beam u u Elite Toei Infogrames Interplay JVC/Lucas_Arts Sculpture u Storm/Sales_Curve u u THQ Accolade Triffix u Microprose u u Kemco Misawa Teichiko Namco Lozc Koei Tokuma_Shoten Tsukuda_Original Datam_Polystar u u u Bullet_Proof_Softw. Vic_Tokai u Character_Soft I-Max Takara Chun_Soft System_3 Interbec u Varie_Corp. Temco Kaneko u Packin_Video Nichibutsu Temco Imagineer u u u Telenet Hori_Electric u u Konami Kac u Takara u Technos JVC u Toei_Animations Toho u Namcot Acclaim Ascii Bandai Various Enix u Hal u u u Culture_Brain Sunsoft Toshiba-EMI Sony_Imagesoft u Sammy Taito u Kemco SquareSoft u Data_East Tonkin_House Ocean Koei u Konami Vap_Inc. u Meldac Pony_Canyon Sotsu_Agency_Sunrise Taito Sofel Quest_Corp. Sigma_Ent. Ask_Kodahae u Naxat_Soft u Capcom Ban_Presto Tomy Hiro u NCS Human Altron Kk_dce u Toei u T_&_E_Soft Epoch u Athena Asmik Natsume King_Records Atlus Sony u Disney u u Motown Left_Field Beam_Software Tec_Magik u u u Jaleco Cybersoft u u u u Davidson'
  251. Manufactor=Word( manuf, Manufactor )
  252. if Manufactor="u" Then Manufactor="Unknown"
  253. x=pos("_",Manufactor)
  254. if x~=0 then Manufactor=left(Manufactor,x-1) right(Manufactor,length(Manufactor)-x)
  255.  
  256. x=pos("\",diz,15)
  257. if x~=0 then diz=left(diz,x-1)
  258. diz=upper(left(diz,1))trim(translate(right(diz,length(diz)-1), xrange('a','z'), xrange('A', 'Z')))
  259. do a=2 to length(diz)
  260.   if big=1 then do
  261.     diz=left(diz,a-1)Upper(right(left(diz,a),1))right(diz,length(diz)-a)
  262.   end
  263.   big=0
  264.   if right(left(diz,a),1)=" " then big=1
  265.   if right(left(diz,a),1)="." then big=1
  266. end
  267.  
  268. if cDIZ then do
  269.   if ftp then do
  270.     call writeln skriv,left(Filepart(afile),15)Right(Word(statef(Afile),2),10) date(E) "- -[ SNES ]------------------------------- -"
  271.     call writeln skriv,"                                   Name:       "diz
  272.     call writeln skriv,"                                   Manufactor: "Manufactor
  273.     call writeln skriv,"                                   GameSize:   "GameSize
  274.     call writeln skriv,"                                   Backupsize: "Backupsize
  275.     call writeln skriv,"                                   Country:    "Country
  276.     call writeln skriv,"                                   - ------------------------[ FXSNESDIZ ]--- -"
  277.     end
  278.   else do
  279.    call writeln skriv,"- -[ SNES ]------------------------------- -"
  280.    call writeln skriv,"Name:       "diz
  281.    call writeln skriv,"Manufactor: "Manufactor
  282.    call writeln skriv,"GameSize:   "GameSize
  283.    call writeln skriv,"Backupsize: "Backupsize
  284.    call writeln skriv,"Country:    "Country
  285.    if cprom=1 then call writeln skriv,"Warring:    Missing 512byte Header"
  286.    call writeln skriv,"- ------------------------[ FXSNESDIZ ]--- -"
  287.   end
  288. end
  289. else if FTP then do
  290.   call writeln skriv,left(Filepart(afile),30) diz' (c) 'Manufactor
  291. end
  292. if COM then address command("Filenote" '"'Afile'"' '"'diz' (c) 'Manufactor'"')
  293.  
  294. /*if ~cdiz & ~ftp & ~com & filearc~=1 then do*/
  295. if ~cdiz & ~ftp & ~com then do
  296.   say ""
  297.   Say "- -[ SNES ]------------------------------- -"
  298.   if list then say "FILE: "afile
  299.   say "Name:       "diz
  300.   Say "Manufactor: "Manufactor
  301.   say "GameSize:   "GameSize
  302.   say "Backupsize: "Backupsize
  303.   say "Country:    "Country
  304.   if cprom=1 then say "Warring:    Missing 512byte Header"
  305.   say "- ------------------------[ FXSNESDIZ ]--- -"
  306. end
  307. call close file
  308. return
  309.  
  310. IOERR:
  311.  Say ' '
  312.  say 'Load Error!';exit
  313. break_c:
  314.  Say ' '
  315.  Say 'Break Error!';exit
  316. syntax:
  317.  Say ' '
  318.  Say 'Syntax Error!'
  319.  if ~exists('Libs:rexxdossupport.library') then Say "SNESDiz Requiers: rexxdossupport.library, Get it From Aminet!"
  320.  if ~exists('Libs:rexxreqtools.library') then Say "SNESDiz Requiers: rexxreqtools.library, Get it From Aminet!"
  321.  if ~exists('Libs:rexxsupport.library') then Say "SNESDiz Requiers: rexxsupport.library"
  322.  exit
  323.